package cn.jobstart.common.word;

import org.apache.poi.xwpf.usermodel.ParagraphAlignment;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFRun;

/**
 * Created with IntelliJ IDEA.
 * User: Yuan.x.i.n@foxmail.com
 *
 * @author Yuan.x.i.n@foxmail.com
 * @Date 2019-11-05 23:06
 * @description
 */
public class WordExport {

    /**
     * word换行
     *
     * @param document
     */
    public static void createWordLineBreak(XWPFDocument document) {
        //换行
        XWPFParagraph paragraph1 = document.createParagraph();
        XWPFRun paragraphRun1 = paragraph1.createRun();
        paragraphRun1.setText("\r");
    }

    public static void createLine(XWPFDocument document, String content) {
        createLine(document, content, 12, false);

    }

    public static void createLine(XWPFDocument document, String content, int fontSize, boolean bold) {
        XWPFParagraph line = document.createParagraph();


        //设置段落居中
        line.setAlignment(ParagraphAlignment.LEFT);

        XWPFRun lineRun = line.createRun();
        lineRun.setText(content);
        lineRun.setColor("000000");
        lineRun.setFontSize(fontSize);
        lineRun.setBold(bold);


    }
}
